home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / MCASM.RAR / MC_ASM.EXE / WROX_ASM / CH4 / PROG4_2.ASM < prev    next >
Assembly Source File  |  1994-11-14  |  2KB  |  70 lines

  1.  
  2. ************************************************************
  3.     Program 4.2 A Resident Beeper
  4.     ************************************************************
  5.         cseg         group cres,cinit
  6.         cres         segment
  7.         assume     cs:cseg
  8.         oldint8    dw     2 dup (?)
  9.         tik         dw     0
  10.         int8        proc    far
  11.                 inc     tik
  12.                 cmp     tik,1092    ; one minute
  13.                 je     sound_on
  14.                 cmp     tik,18        ; one second
  15.                 je     sound_off
  16.                 jmp     dword ptr oldint8
  17.     sound_on:            
  18.                 push     ax
  19.                 mov     tik,0
  20.     
  21.                 in     al,61h        ; Get port setting
  22.                 or     al,3
  23.                 out     61h,al        : Turn speaker on
  24.                 mov     al,0b6h        ; control word 0B6h (10110110b)
  25.                             ; switche channel 2 ofthe timer
  26.                             ; into mode 3,
  27.                             ; binary count,
  28.                             ; load least significant byte first,
  29.                             ; most significant byte next.
  30.  
  31.                 out     43h,al
  32.                 mov     al,9        ; 1.19/1709h Mhz (frequency divisor)
  33.                 out     42h,al        ; load low part
  34.                 mov     al,17h
  35.                 out     42h,al        ; load high part
  36.                 pop     ax
  37.                 jmp     dword ptr oldint8
  38.     sound_off:
  39.                 push     ax
  40.                 in     al,61h        ; Get port setting
  41.                 and    al,0fch
  42.                 out     61h,al        ; Turn speaker off
  43.                 pop     ax
  44.                 jmp     dword ptr oldint8
  45.     int8         endp
  46.     cres         ends
  47.      
  48.     cinit          segment
  49.     start:
  50.                 push     ds
  51.                 mov     ax,3508h
  52.                 int     21h        ; Get old Int 8 vector
  53.                 mov     oldint8,bx
  54.                 mov     oldint8+2,es
  55.     
  56.                 push     cs
  57.                 pop     ds
  58.                 lea     dx,int8
  59.                  mov     ax,2508h
  60.                  int     21h        ; Set new Int 8 vector
  61.     
  62.                 pop     dx
  63.                 sub     dx,cinit    
  64.                 neg     dx        ; Get # of paragraphs to keep
  65.                 mov     ax,3100h
  66.                 int     21h        ; Keep program in memory
  67.     cinit         ends
  68.                 end     start
  69.  
  70.